package cn.k23.config;

import cn.k23.config.autoconfig.TokenProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import cn.k23.interceptor.TokenInterceptor;
/**
 * @Description: 注册拦截器
 * @Author: k23
 * @Date: 2022-05-10 10:31
 * @Version: 1.0
 */
public class TokenInterceptorRegistry implements WebMvcConfigurer {

    @Autowired
    TokenProperties properties;

    @Autowired
    TokenInterceptor tokenInterceptor;



    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns(properties.getPathPatterns()) //token拦截的路径
                .excludePathPatterns(properties.getExcludePathPatterns()); //token不拦截的路径
    }


}
